<template>
  <div class="table-box">
    <div class="operation-box">
      <div class="input-box">
        任务编号：
        <el-input
          v-model="search"
          placeholder="请输入关键字"
          class="input__item"
        />
        <el-button type="danger">查询</el-button>
      </div>

      <el-button type="primary">保存</el-button>
    </div>

    <el-table
      :data="tableData"
      stripe
      border
      table-layout="auto"
      style="max-width: 90vw; min-width: 1000px"
    >
      <el-table-column prop="id" label="杆塔编号" />
      <el-table-column prop="route" label="线路编号" />
      <el-table-column prop="tower" label="杆塔编号" />
      <el-table-column prop="defect" label="缺陷类型" />
      <el-table-column prop="percent" label="完好率" />
      <el-table-column prop="detail" label="缺陷描述" />
      <el-table-column prop="time" label="发现时间" />
      <el-table-column prop="name" label="发现人员" />
      <el-table-column fixed="right" label="缺陷级别">
        <template #default="scope">
          <el-select
            v-model="tableData[scope.$index].level"
            placeholder="请选择"
            style="width: 240px"
          >
            <el-option
              v-for="item in levels"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";

const search = ref("");

const levels = [
  {
    value: "1",
    label: "一般",
  },
  {
    value: "2",
    label: "紧急",
  },
  {
    value: "3",
    label: "严重",
  },
];

const tableData = ref([
  {
    id: "XW00001",
    route: "XW00010",
    tower: "XW0001",
    defect: "拦河线断裂",
    percent: 87,
    detail: "拦河线断裂严重",
    time: "2013/12/12",
    name: "巡检员测试用户01",
    level: "",
    state: false,
  },
  {
    id: "XW00001",
    route: "XW00010",
    tower: "XW0001",
    defect: "拦河线断裂",
    percent: 87,
    detail: "拦河线断裂严重",
    time: "2013/12/12",
    name: "巡检员测试用户01",
    level: "",
    state: false,
  },
  {
    id: "XW00001",
    route: "XW00010",
    tower: "XW0001",
    defect: "拦河线断裂",
    percent: 87,
    detail: "拦河线断裂严重",
    time: "2013/12/12",
    name: "巡检员测试用户01",
    level: "",
    state: false,
  },
  {
    id: "XW00001",
    route: "XW00010",
    tower: "XW0001",
    defect: "拦河线断裂",
    percent: 87,
    detail: "拦河线断裂严重",
    time: "2013/12/12",
    name: "巡检员测试用户01",
    level: "",
    state: false,
  },
]);
</script>

<style scoped>
.table-box {
  width: fit-content;
  margin: 0 auto;
}

.operation-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-box {
  color: #747070;
  font-size: 14px;
}

.input__item {
  width: 250px;
  margin: 10px;
}
</style>
